<template>
  <div class="tag-input-wrap">
    <span>{{ name }}:</span>
    <a-input
      class="tag-input"
      v-model="miniV"
      placeholder="1000.0"
      size="small"
      type="number"
    ></a-input>
    <span>-</span>
    <a-input
      class="tag-input"
      v-model="maxV"
      placeholder="1500.0"
      size="small"
      type="number"
    ></a-input>
    <a-button
      class="tag-btn"
      size="small"
      @click="sure"
      :disabled="enterDisabled"
      >确定</a-button
    >
  </div>
</template>

<script>
export default {
  props: {
    name: String,
    initFunc: Function // 初始化函数
  },
  data() {
    return {
      miniV: null,
      maxV: null
    }
  },
  computed: {
    enterDisabled() {
      return !(!!this.miniV && !!this.maxV)
    }
  },
  methods: {
    sure() {
      const { miniV, maxV } = this
      this.$emit('sure', { miniV, maxV })
    },
    initV() {
      this.initFunc.call(this) // 初始化值
    }
  }
}
</script>
